package com.yx.enterresourceplanning.controller;

import com.yx.enterresourceplanning.entity.Department;
import com.yx.enterresourceplanning.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/dept")
public class DeptController {
    @Autowired
    private DeptService deptService;

    @GetMapping("/list")
    public List<Department> getListDept()
    {
        return deptService.getListDept();
    }
    @PostMapping("/listByType")
    public List<Department> getListDeptByType(@RequestParam(name = "type")String type)
    {
        return deptService.getListDeptByType(type);
    }
    @PostMapping("/addDept")
    public int addDept(@RequestParam(name = "depId")String depId,@RequestParam(name = "department")String department,
                       @RequestParam(name = "type")String type
                       )
    {
        return deptService.addDept(depId,department,type);
    }
}
